import customStorage from "./customStorage";
export default ({ separator, group, isJson, isSession } = {}) => {
  const storage = isSession ? window.sessionStorage : window.localStorage;
  const custom = customStorage({
    separator,
    group,
    isJson: isJson === false ? false : true,
    customSetItem(key, value) {
      storage.setItem(key, value);
    },
    customGetItem(key) {
      return storage.getItem(key);
    },
    customRemoveItem(key) {
      storage.removeItem(key);
    },
  });
  return {
    ...custom,
    clear() {
      custom.clear(Object.keys(storage));
    },
  };
};
